import React from "react";
import { HashRouter as Router, Route, Switch } from "react-router-dom";
import { Provider } from "react-redux";
import store from "./store";
import PrivateRoute from '@/components/PrivateRoute'

import Home from "./views/home";

import Cart from "./views/cart";
import Login from "./views/login";
import Register from "./views/register";
import Money from "./views/money";
import Special from "./views/special";

import GoodsList from "./views/goodsList";
import Details from "./views/details";

import Search from "./views/search";
import Center from "./views/center";
import SearchGoods from "./views/searchgoods"

import TabBar from "@/components/tabBar";

class App extends React.Component {
  render() {
    return (
      <Router>
        <Provider store={store}>
          <TabBar />
          <Switch>
            <PrivateRoute path="/money" component={Money} />
            <Route path="/register" component={Register} />
            <Route path="/goodsList">
              <GoodsList goods={this.props.goods} />
            </Route>
            <Route path="/details/:id" component={Details} />
            <Route path="/special" component={Special} />
            <Route path="/searchgoods/:name" component={SearchGoods} />
            <Route path="/search" component={Search} />
            <Route path="/center" component={Center} />
            <Route path="/login" component={Login} />
            <Route path="/cart" component={Cart} />
            <Route path="/" component={Home} />
          </Switch>
        </Provider>
      </Router>
    );
  }
}

export default App;
